/*
* npm run dev
*
* 需要在本地机器绑定host
* 127.0.0.1 assertsdev.xcarimg.com
*
* */
let webpack = require('webpack');
let path = require('path');
let ExtractTextPlugin = require("extract-text-webpack-plugin");
let ResPlugin=require('xtouch-res-webpack-plugin');
let res =require('./res.config/res.config');

module.exports = {
    entry: res.entry,
    output: {
        path: path.join(__dirname, res.publicPath),
        filename: './js/[name].js',
        chunkFilename: "./js/[name].js",
        publicPath: 'http://assertsdev.xcarimg.com:8080/dist/v1.0/',
        libraryTarget: "umd"
    },
    devServer: {
        inline: true,
        public: 'assertsdev.xcarimg.com',
         
    },
    module: {
        rules: [
            {
                test: /\.css$/,
                use: ['style-loader',{
                    loader: 'css-loader',
                    options: {
                        minimize: true
                    }
                }
                ]
            },{
                test: /.js$/,
                enforce: 'post', // post-loader处理
                loader: 'es3ify-loader'
            },
            {
                test: /\.js$/,
                //exclude: /(node_modules|bower_components)/,
                loader: 'babel-loader',
                query: {
                    presets: ['es2015-loose'], // 更贴近ES5，可兼容更多浏览器，比如说IE9
                    'plugins': [
                        'transform-remove-strict-mode',
                        'transform-es3-property-literals',
                        'transform-es3-member-expression-literals'
                    ]
                } 
            },

            {
                test: /\.(scss)$/,
                use: ExtractTextPlugin.extract({
                    fallback: "style-loader",
                    use: [{
                        loader: 'css-loader',
                        options: {
                            minimize: true
                        }
                    },"sass-loader"]
                })
            },

            {
                test: /\.(gif|jpg|png|svg)\??.*$/,
                loader: 'url-loader?limit=8192&name=images/[hash:8].[ext]'
            } ,
            {
                test: /\.(woff|eot|ttf)\??.*$/,
                loader: 'url-loader?limit=1111118192&name=font/[hash:8].[ext]'
            },
            { //解析 .ejs
                test: /\.ejs/,
                loader: 'ejs-loader'
            }
        ]
    },
    plugins: [
        new ExtractTextPlugin('css/[name].css'),

    ]
}
